import { createRouter, createWebHashHistory } from 'vue-router'
import homeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/User/index.vue')
    },
    {
      path: '/',
      name: 'home',
      component: homeView
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/404',
      name: '404',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: ()=>import('../views/404.vue')
    },
    {path:"/:pathMatch(.*)",redirect:'/404',hidden:true}
  ]
})
export function resetRouter(){
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}
export default router
